﻿Imports System.Data.SqlClient

Public Class clsRELOJ_CHECADOR
    Private cnConn As New SqlConnection
    Private Command As SqlCommand
    Public Sub CONECTAR_BD()
       Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Command = New SqlCommand("INSERT INTO CHECKINOUT VALUES(@USERID,@CHECKTIME,@CHECKTIPE,@SENSORID)", cnConn)
        Command.CommandTimeout = 0

        Command.Parameters.Add(New SqlParameter("@USERID", SqlDbType.Int))
        Command.Parameters.Add(New SqlParameter("@CHECKTIME", SqlDbType.DateTime))
        Command.Parameters.Add(New SqlParameter("@CHECKTIPE", SqlDbType.VarChar, 1))
        Command.Parameters.Add(New SqlParameter("@SENSORID", SqlDbType.Int))

        Try
            cnConn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try

    End Sub
    Public Sub Insertar(ByVal USERID As Integer, ByVal CHECKTIME As DateTime, ByVal CHECKTYPE As String, ByVal SENSORID As Integer)
        Command.Parameters("@USERID").Value = USERID
        Command.Parameters("@CHECKTIME").Value = CHECKTIME
        Command.Parameters("@CHECKTIPE").Value = CHECKTYPE
        Command.Parameters("@SENSORID").Value = SENSORID

        Try
            Command.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")

        End Try
    End Sub

    Public Sub Cerrar_BD()
        If cnConn.State = ConnectionState.Open Then
            cnConn.Close()
        End If
    End Sub
End Class
